var app = getApp()
Page({
  data: {
    /** 
        * 页面配置 
        */
    publicUrl: app.globalData.publicUrl,
    winWidth: 0,
    winHeight: 0,
    // tab切换  
    currentTab: 0,
    cub:1
  },
  stopTouchMove: function () {
    return false;
  },
  onLoad: function (options) {
    var that = this;
    // 初次加载
    /** 
     * 获取系统信息 
     */
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }
    });
  },
  /** 
   * 点击tab切换 
   */
  swichNav: function (e) {
    var that = this;
    /*** 通过任务状态 **/
    /*** 实现点击切换 ***/
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
    // 走接口获取数据
    wx.request({
      url: that.data.publicUrl + 'user_jd_order',
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data: {
        id: wx.getStorageSync('uid'),
        type: e.target.dataset.status
      },
      success: function (res) {
        that.setData({
          list: res.data.data
        })
      },
      fail: function (res) {
        console.log('加载失败')
      }
    }) 
    // 
  },
  onShow: function () {
    /**暂时 这是默认加载'已完成、当前用户id‘的数据 ***/
    console.log('呵呵呵');
    var that = this
    wx.request({
      url: that.data.publicUrl +'user_jd_order',
      method:'POST',
      header:{
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data:{
        id: wx.getStorageSync('uid'),
        type: that.data.cub
      },
      success:function(res){
        console.log(res.data.data);
        console.log('进来了');
        that.setData({
          list:res.data.data
        })
      },
      fail:function(res){
        console.log('加载失败')
      }
    }) 
  },
  navigator:function(e){
    var that = this,
      cub = e.target.dataset.cub,
      id = e.target.dataset.id,
      jd = e.target.dataset.jd
      that.setData({
        cub: e.target.dataset.cub,
        
      })
    wx.navigateTo({
      url: '/pages/myrelease/ordering/ordering?id=' + id + '&cub=' + cub + '&jd=' + jd
    })
  },
})  